<?php include('scripts.php'); ?>

<script type="text/javascript" language="javascript">
    $(function() {
        $("#ecreditForm").validate({
            messages : {
                transactionPassword: {
                    remote: "Security Password is not valid."
                }
            },
            rules : {
                "transactionPassword" : {
                    required : true
                    , remote: "/member/verifyTransactionPassword"
                }
            },
            submitHandler: function(form) {
                waiting();
                var ecashBalance = $('#ecashBalance').autoNumericGet();
                var epointAmount = parseFloat($("#cbo_epointAmount").val());

                if (epointAmount > parseFloat(ecashBalance)) {
                    alert("In-sufficient MT4 Credit");
                    return false;
                }

                form.submit();
            }
        });
    });
</script>

<div style="padding: 10px; top: 30px; width: 98%">
<div class="portlet">
    <div class="portlet-header"><?php echo __('Convert e-Cash To e-Point') ?></div>
    <div class="portlet-content">

    <?php if ($sf_flash->has('successMsg')): ?>
        <div class="ui-widget">
            <div style="margin-top: 10px; margin-bottom: 10px; padding: 0 .7em;"
                 class="ui-state-highlight ui-corner-all">
                <p style="margin: 10px"><span style="float: left; margin-right: .3em;"
                                              class="ui-icon ui-icon-info"></span>
                    <strong><?php echo $sf_flash->get('successMsg') ?></strong></p>
            </div>
        </div>
        <?php endif; ?>
    <?php if ($sf_flash->has('errorMsg')): ?>
        <div class="ui-widget">
            <div style="margin-top: 10px; margin-bottom: 10px; padding: 0 .7em;"
                 class="ui-state-error ui-corner-all">
                <p style="margin: 10px"><span style="float: left; margin-right: .3em;"
                                              class="ui-icon ui-icon-alert"></span>
                    <strong><?php echo $sf_flash->get('errorMsg') ?></strong></p>
            </div>
        </div>
    <?php endif; ?>

    <form action="<?php echo url_for("/member/convertEcashToEpoint") ?>" id="ecreditForm" name="ecreditForm" method="post">
        <table cellpadding="0" cellspacing="5" align="center" border="0">
            <colgroup>
                <col width="30%">
                <col width="69%">
            </colgroup>
            <tbody>

            <tr class="tbl_form_row_odd">

                <td><?php echo __('e-Cash Balance'); ?></td>
                <td>
                    <input name="ecashBalance" id="ecashBalance" tabindex="1" disabled="disabled"
                                       value="<?php echo number_format($ledgerAccountBalance, 2); ?>"/>
                </td>

            </tr>

            <tr class="tbl_form_row_even">

                <td><?php echo __('Converted Amount'); ?></td>
                <td>
                    <select name="epointAmount" id="cbo_epointAmount" tabindex="2">
                        <option value="50">50</option>
                        <option value="200">200</option>
                        <option value="500">500</option>
                        <option value="1000">1,000</option>
                        <option value="1500">1,500</option>
                        <option value="2000">2,000</option>
                        <option value="2500">2,500</option>
                        <option value="3000">3,000</option>
                        <option value="3500">3,500</option>
                        <option value="4000">4,000</option>
                        <option value="4500">4,500</option>
                        <option value="5000">5,000</option>
                        <?php
                            for ($i = 6000; $i <= 100000; $i = $i + 1000) {
                                echo "<option value='".$i."'>".number_format($i, 0)."</option>";
                            }

                        ?>
                    </select>
                </td>

            </tr>

            <tr class="tbl_form_row_odd">

                <td><?php echo __('Security Password'); ?></td>
                <td>
                    <input name="transactionPassword" type="password" id="transactionPassword"
                                       tabindex="3"/>
                </td>

            </tr>

            <tr class="tbl_form_row_odd">

                <td colspan="2" align="center">
                    <font color="#dc143c"><?php echo __('NOTE: e-Point is ONLY for package purchase, package upgrade and is NON-WITHDRAWABLE.') ?></font>
                </td>

            </tr>

            <tr class="tbl_form_row_odd">

                <td align="center" colspan="2">
                    <button id="btnTransfer"><?php echo __('Submit') ?></button>
                </td>

            </tr>
            </tbody>
        </table>

    </form>
    </div>
</div>
</div>